from flask_sqlalchemy import SQLAlchemy
from flask import Flask

app = Flask(
    __name__,
    template_folder="../apis/templates",
    static_folder="../static",
    static_url_path="/static",
)
app.config["SQLALCHEMY_DATABASE_URI"] = (
    "mysql+pymysql://root:root@localhost:3306/boot-note?charset=utf8mb4"
)
app.config["SQLALCHEMY_POOL_SIZE"] = 20  # 设置连接池大小
app.config["SQLALCHEMY_POOL_TIMEOUT"] = 10  # 设置连接池超时时间
app.config["SQLALCHEMY_POOL_RECYCLE"] = 3600  # 设置连接多久后自动断开并重新连接（秒）
app.config["SQLALCHEMY_MAX_OVERFLOW"] = 10  # 设置超出连接池大小后，允许的最大连接数
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False  # 关闭修改跟踪，减少内存消耗
app.config["SQLALCHEMY_ECHO"] = "true"  # 显示生成的SQL语句，可用于调试
db = SQLAlchemy(app)
